package com.xwm93up.basic.enumtips;

/**
 * @Description: desc
 * @Author: xwm93up
 * @Since: 2021/11/30 14:42
 */
public class CalculatorTest {
    public enum Calculator {
        ADDITION {
            public Double execute(Double x, Double y) {
                return x + y; //加法
            }
        },
        SUBTRACTION {
            public Double execute(Double x, Double y) {
                return x - y; //减法
            }
        },
        MULTIPLICATION {
            public Double execute(Double x, Double y) {
                return x * y; //乘法
            }
        },
        DIVISION {
            public Double execute(Double x, Double y) {
                return x/y; // 除法
            }
        };

        public abstract Double execute(Double x, Double y);
    }

    public static void main(String[] args) {
        System.out.println(Calculator.ADDITION.execute(4.0, 2.0)); //6.0
        System.out.println(Calculator.SUBTRACTION.execute(4.0, 2.0)); //2.0
        System.out.println(Calculator.MULTIPLICATION.execute(4.0, 2.0)); //8.0
        System.out.println(Calculator.DIVISION.execute(4.0, 2.0)); //2.0
    }
}
